package cn.dakaqi.entities;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by chunyang on 2016/4/16.
 * 社团成员
 */
@Entity
@Table(name = "U_GROUP_VOLUNTEER")
public class GroupVolunteer extends IdEntity
{

    private Volunteer volunteer;    //志愿者
    private Group group;            //社团
    private int role;              //身份 0志愿者 1管理员 2创建人
    private int status;             //审核状态
    private Date createTime;        //加入日期
    private String demo;            //备注
    private int delStatus;          //删除
    private String refuseCase;      //拒绝理由
    private long times = 0L;        //当前会员在当前社团累计完成的公益时间
    public GroupVolunteer()
    {
    }

    public GroupVolunteer(Long id)
    {
        this.id = id;
    }

    public long getTimes()
    {
        return times;
    }

    public void setTimes(long times)
    {
        this.times = times;
    }

    public String getRefuseCase()
    {
        return refuseCase;
    }

    public void setRefuseCase(String refuseCase)
    {
        this.refuseCase = refuseCase;
    }

    public int getDelStatus()
    {
        return delStatus;
    }

    public void setDelStatus(int delStatus)
    {
        this.delStatus = delStatus;
    }

    @ManyToOne
    @JoinColumn(name = "VOLUNTEER_ID")
    @JsonIgnore
    public Volunteer getVolunteer()
    {
        return volunteer;
    }

    public void setVolunteer(Volunteer volunteer)
    {
        this.volunteer = volunteer;
    }

    @ManyToOne
    @JoinColumn(name = "GROUP_ID")
    @JsonIgnore
    public Group getGroup()
    {
        return group;
    }

    public void setGroup(Group group)
    {
        this.group = group;
    }

    public int getRole()
    {
        return role;
    }

    public void setRole(int role)
    {
        this.role = role;
    }

    public int getStatus()
    {
        return status;
    }

    public void setStatus(int status)
    {
        this.status = status;
    }

    // 设定JSON序列化时的日期格式
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime()
    {
        return createTime;
    }

    public void setCreateTime(Date createTime)
    {
        this.createTime = createTime;
    }

    public String getDemo()
    {
        return demo;
    }

    public void setDemo(String demo)
    {
        this.demo = demo;
    }

    //    @Override
//    public String toString() {
//        return ToStringBuilder.reflectionToString(this);
//    }
}
